package com.ruoyi.mybatchscheduling.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mybatchscheduling.domain.Mybatchscheduling;
import com.ruoyi.mybatchscheduling.service.IMybatchschedulingService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 任务信息Controller
 * 
 * @author xiangwenbiin
 * @date 2024-01-27
 */
@RestController
@RequestMapping("/mybatchscheduling")
public class MybatchschedulingController extends BaseController
{
    @Autowired
    private IMybatchschedulingService mybatchschedulingService;

    /**
     * 查询任务信息列表
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:list")
    @GetMapping("/list")
    public TableDataInfo list(Mybatchscheduling mybatchscheduling)
    {
        startPage();
        List<Mybatchscheduling> list = mybatchschedulingService.selectMybatchschedulingList(mybatchscheduling);
        return getDataTable(list);
    }

    /**
     * 导出任务信息列表
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:export")
    @Log(title = "任务信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mybatchscheduling mybatchscheduling)
    {
        List<Mybatchscheduling> list = mybatchschedulingService.selectMybatchschedulingList(mybatchscheduling);
        ExcelUtil<Mybatchscheduling> util = new ExcelUtil<Mybatchscheduling>(Mybatchscheduling.class);
        util.exportExcel(response, list, "任务信息数据");
    }

    /**
     * 获取任务信息详细信息
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:query")
    @GetMapping(value = "/{No}")
    public AjaxResult getInfo(@PathVariable("No") Long No)
    {
        return success(mybatchschedulingService.selectMybatchschedulingByNo(No));
    }

    /**
     * 新增任务信息
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:add")
    @Log(title = "任务信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mybatchscheduling mybatchscheduling)
    {
        return toAjax(mybatchschedulingService.insertMybatchscheduling(mybatchscheduling));
    }

    /**
     * 修改任务信息
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:edit")
    @Log(title = "任务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mybatchscheduling mybatchscheduling)
    {
        return toAjax(mybatchschedulingService.updateMybatchscheduling(mybatchscheduling));
    }

    /**
     * 删除任务信息
     */
    @RequiresPermissions("mybatchscheduling:mybatchscheduling:remove")
    @Log(title = "任务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Nos}")
    public AjaxResult remove(@PathVariable Long[] Nos)
    {
        return toAjax(mybatchschedulingService.deleteMybatchschedulingByNos(Nos));
    }
}
